// run: $exec < input_c
#include <iostream>

int const maxn = 550;
bool a[maxn][maxn];
long long f[maxn][maxn];
int n, m, q;

int main()
{
	std::cin >> n >> m;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++) {
			char ch; std::cin >> ch;
			a[i][j] = ch == '.';
		}

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++) {
			f[i][j] = f[i][j - 1] + f[i - 1][j] - f[i - 1][j - 1];
			if (a[i][j] && a[i][j - 1]) f[i][j]++;
			if (a[i][j] && a[i - 1][j]) f[i][j]++;
		}

	std::cin >> q;
	for (int i = 0, x1, y1, x2, y2; i < q; i++) {
		std::cin >> x1 >> y1 >> x2 >> y2;
		long long ans = f[x2][y2] - f[x2][y1 - 1] - f[x1 - 1][y2] + f[x1 - 1][y1 - 1];
		for (int j = y1; j <= y2; j++)
			if (a[x1][j] && a[x1 - 1][j]) ans--;
		for (int j = x1; j <= x2; j++)
			if (a[j][y1] && a[j][y1 - 1]) ans--;
		std::cout << ans << '\n';
	}
}

